import request from '@/utils/request'

// 获取商品详情
export const findGoods = (id) => {
  return request('/goods', 'get', { id })
}

// 获取热榜商品
export const findHotGoods = ({ id, type, limit = 3 }) => {
  return request('/goods/hot', 'get', { id, type, limit })
}

// 加入购物车
export const insertCart = ({ skuId, count }) => {
  return request('/member/cart', 'post', { skuId, count })
}

// 获取购物车列表
export const findCartList = () => {
  return request('/member/cart', 'get')
}

// 删除商品
export const deleteCart = (ids) => {
  return request('/member/cart', 'delete', { ids })
}

// 修改购物车商品的状态和数量
export const updateCart = (goods) => {
  return request('/member/cart/' + goods.skuId, 'put', goods)
}

// 全选
export const checkAllCart = ({ selected, ids }) => {
  return request('/member/cart/selected', 'put', { selected, ids })
}
